package cn.shengchao.examstar.knowledge.application.service;

import cn.shengchao.examstar.knowledge.domain.entity.KnowledgePoint;
import cn.shengchao.examstar.knowledge.domain.repository.KnowledgePointRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 知识点应用服务类
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class KnowledgePointService {

    private final KnowledgePointRepository knowledgePointRepository;

    /**
     * 获取类目知识点总数
     * @param specificationTypeId 类目ID
     * @return 知识点总数
     */
    public int getCategoryKnowledgePointCount(Long specificationTypeId) {
        if (specificationTypeId == null) {
            log.warn("类目ID为空，无法获取知识点总数");
            return 0;
        }
        
        List<KnowledgePoint> knowledgePoints = knowledgePointRepository.findBySpecificationTypeId(specificationTypeId);
        int count = knowledgePoints.size();
        log.info("类目[{}]的知识点总数: {}", specificationTypeId, count);
        
        return count;
    }
} 